<input type="hidden" value="${ctx}" id="basePath">

<!DOCTYPE html>
<html>


<!-- Mirrored from www.zi-han.net/theme/hplus/empty_page.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:19:52 GMT -->
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>试题修改</title>

    <link href="${ctx}/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${ctx}/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="${ctx}/css/animate.min.css" rel="stylesheet">
    <link href="${ctx}/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <!--单选框样式-->
    <link href="${ctx}/css/labelauty.css" rel="stylesheet"/>

    <script src="${ctx}/js/jquery.min.js?v=2.1.4"></script>
    <script src="${ctx}/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="${ctx}/js/content.min.js?v=1.0.0"></script>
    <script src="${ctx}/js/plugins/layer/layer.js"></script>
    <script src="${ctx}/js/exam/exam-update.js"></script>
    <#--表单验证-->
    <link href="${ctx}/parsley/parsley.css" rel="stylesheet">
    <script src="${ctx}/parsley/parsley.min.js"></script>
    <style type="text/css">
        .check-image {
            background: url(${ctx}/images/input-unchecked.png) no-repeat;
        }
        /**********************************自定义单选框样式******************************************/
        .rdo {
            height: 34px;
            border: 1px solid #e5e6e7;
        }

        .rdobox {
            border-radius: 0;
            height: 34px;
        }

        /**********************************自定义单选框样式******************************************/

        label {
            margin-bottom: 0px;
        }

        .waring {
            position: fixed;
            top: 18%;
            right: 12%;
            min-height: 80px;
            width: 15%;
        }

        /*去圆角*/
        .nav-tabs li a {
            border-radius: 0 0 0 0;
        }
    </style>
</head>
<body class="gray-bg" onload="getTime(),loadAnswer('#answer-content-acupoint-location-pediatric-location')">
<br>
<div class="wrapper wrapper-content animated fadeInUp waring">
    <ul class="notes">
        <li>
            <div style="transform:rotate(0deg);">
                <small id="date-time" style="text-align: left;width: 92%"></small>
                <br>
                <h4>温馨提示</h4>
                <p><span class="glyphicon glyphicon-triangle-right" style="color: limegreen" ></span>试题题干不可与已存在的试题题干相同，系统将会对此进行验证。</p>
                <p><span class="glyphicon glyphicon-triangle-right" style="color: limegreen" ></span>需要增加定位、主治或者答案项时，请点击添加按钮。</p>
                <p><span class="glyphicon glyphicon-triangle-right" style="color: limegreen" ></span>需要减少答案或者主治项时，请点击“叉号”进行删除。</p>
            </div>
        </li>
    </ul>
</div>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="tabbable" id="tabs-576364">
                <ul class="nav nav-tabs">
                    <li><a >问答题</a></li>
                    <li class="active"><a href="#panel-2" data-toggle="tab">穴位定位</a></li>
                    <li><a>单项手法</a></li>
                    <li><a>成套手法</a></li>
                </ul>
                <br/>
                <div class="tab-content">
                    <div class="tab-pane active" id="panel-1">
                        <form class="form-horizontal" id="table-example">
                            <div class="col-md-9">
                                <input type="hidden" value="${exam.id}" name="id"/>
                                <!--试题分类-->
                                <div class="form-group">
                                    <label class="col-md-2 control-label">分类</label>
                                    <div class="col-md-9">
                                        <div class="rdo">
                                            <!--成人穴位-->
                                            <input type="radio" name="categoryId" class="rdolist" value="8"/>
                                            <label class="rdobox" radio-exam-category-val="8">
                                                <span class="check-image"></span>
                                                <span class="radiobox-content">成人穴位</span>
                                            </label>
                                            <!--儿科穴位-->
                                            <input type="radio" name="categoryId" class="rdolist" value="7"/>
                                            <label class="rdobox" radio-exam-category-val="7"  id="radio-exam-acupoint-adult">
                                                <span class="check-image"></span>
                                                <span class="radiobox-content">儿科穴位</span>
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <#include "common.ftl">
                                <!--问答题答案模板-->
                                <!--部位-->
                                <div class="form-group ">
                                    <label class="col-sm-2 control-label">部位</label>
                                    <div class="col-sm-6">
                                        <select name="partIdPediatric" class="form-control">
                                        <#list partList as item>
                                            <option value="${item.id}" <#if item.id == exam.partIdPediatric>selected</#if>>${item.part}</option>
                                        </#list>
                                        </select>
                                    </div>
                                    <label class="col-sm-1 control-label">分值</label>
                                    <div class="col-sm-2">
                                        <input type="text" class="form-control" name="partScorePediatric" value="${exam.partScorePediatric}"
                                               parsley-trigger="change" required data-parsley-range="[0,${examParamAcupointLocationPediatric.maxPartScore}]"/>
                                    </div>
                                </div>
                                <!--具体部位-->
                                <div class="form-group ">
                                    <label class="col-sm-2 control-label">具体部位</label>
                                    <div class="col-sm-6">
                                        <input type="text" class="form-control" name="partDetailPediatric" value="${exam.partDetailPediatric}"
                                               parsley-trigger="change" required maxlength="250" data-parsley-maxlength="250"/>
                                    </div>
                                    <label class="col-sm-1 control-label">分值</label>
                                    <div class="col-sm-2">
                                        <input type="text" class="form-control" name="partDetailScorePediatric" value="${exam.partDetailScorePediatric}"
                                               parsley-trigger="change" required data-parsley-range="[0,${examParamAcupointLocationPediatric.maxPartDetailScore}]"/>
                                    </div>
                                </div>
                                <!--定位-->
                                <div id="answer-content-acupoint-location-pediatric-location">
                                    <div class="form-group ">
                                        <label class="col-sm-2 control-label">定位</label>
                                        <div class="col-sm-6">
                                            <input type="text" class="form-control" name="location1Pediatric" value="${exam.location1Pediatric}"
                                                   parsley-trigger="change" required maxlength="250" data-parsley-maxlength="250"/>
                                        </div>
                                        <label class="col-sm-1 control-label">分值</label>
                                        <div class="col-sm-2">
                                            <input type="text" class="form-control" name="location1ScorePediatric" value="${exam.location1ScorePediatric}"
                                                   parsley-trigger="change" required data-parsley-range="[0,${examParamAcupointLocationPediatric.maxLocationScore}]"/>
                                        </div>
                                        <div class="col-sm-1">
                                            <button class="btn  btn-primary" type="button" onclick="addTerms('#answer-content-acupoint-location-pediatric-location',2,'定位项已达上限','acupointLocationPediatricLocation')"><i class="glyphicon glyphicon-plus"></i>&nbsp;添加</button>
                                        </div>
                                    </div>
                                </div>
                                <div id="answer-content-acupoint-location"></div>
                                <div class="form-group">
                                    <div class="col-md-6" style="text-align: center;">
                                        <button type="button" onclick="submitForm()"class="btn btn-primary" style="background-color: #008200; color: white;">提交</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<input type="hidden" value="<#if exam.location2Pediatric ??>${exam.location2Pediatric}</#if>" id="location2">
<input type="hidden" value="<#if exam.location2ScorePediatric ??>${exam.location2ScorePediatric}</#if>" id="location2Score">
<input type="hidden" value="<#if exam.location3Pediatric ??>${exam.location3Pediatric}</#if>" id="location3">
<input type="hidden" value="<#if exam.location3ScorePediatric ??>${exam.location3ScorePediatric}</#if>" id="location3Score">
</body>
<script type="text/javascript">
    $(document).ready(function () {
        $("#radio-exam-acupoint-adult").removeClass("unchecked");
        $("#radio-exam-acupoint-adult").addClass("checked");
        $("#radio-exam-acupoint-adult").find(".check-image").css("background", "url(" + basePath + "/images/input-checked.png)");

    });

    function submitForm() {
        if (!$('#table-example').parsley().validate()) {
            return;
        }
        var totalScore=getTotalScoreAcupointLocationPediatric();
        $("#total-score").val(totalScore)
        if (totalScore>'${examParamAcupointLocationPediatric.maxTotalScore}') {
            layer.alert('总分超过上限，请修改!', {
                closeBtn: 0
            });
            return;
        }
        var url = '${ctx}/exam/examManage/update/examAcupointPediatric';
        $.ajax({
            type: "POST",
            dataType: "JSON",
            url: url,
            data: $('#table-example').serialize(),
            success: function (data) {
                if (data.code == 0) {
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 4000
                    });
                }else{
                    layer.alert(data.msg, {
                        closeBtn: 0
                    });
                }
            },
            error: function(data) {
                layer.alert(data.msg, {
                    closeBtn: 0
                });
            }
        });
    }
    var validateAnswerText="parsley-trigger='change' required maxlength='250' data-parsley-maxlength='250' ";
    var validateAnswerScoreLocationText="parsley-trigger='change' required data-parsley-range='[0,${examParamAcupointLocationPediatric.maxLocationScore}]'"

    function  loadAnswer(divId1) {
        var content;
        var location2= $("#location2").val() ;
        var location2Score=$("#location2Score").val();
        var location3= $("#location3").val() ;
        var location3Score=$("#location3Score").val();
        /*初始化定位答案*/
        if (location2 != '' && location2Score != '') {
            acupointLocationPediatricCount++;
            content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6'><input type='text' "+validateAnswerText+" class='form-control' name='answer' value=\"<#if exam.location2Pediatric ??>${exam.location2Pediatric}</#if>\"/></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2'><input type='text'  "+validateAnswerScoreLocationText+"class='form-control' name='answerScore'  value=\"<#if exam.location2ScorePediatric ??>${exam.location2ScorePediatric}</#if>\"/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"acupointLocationPediatricCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
            $(divId1).append(content);
        }
        if (location3 != '' && location3Score != '') {
            acupointLocationPediatricCount++;
            content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6'><input type='text' "+validateAnswerText+" class='form-control' name='answer' value=\"<#if exam.location3Pediatric ??>${exam.location3Pediatric}</#if>\"/></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2'><input type='text'  "+validateAnswerScoreLocationText+"class='form-control' name='answerScore'  value=\"<#if exam.location3ScorePediatric ??>${exam.location3ScorePediatric}</#if>\"/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"acupointLocationPediatricCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
            $(divId1).append(content);
        }
    }

    function addTerms(divId,count,msg,category) {
        if (acupointLocationPediatricCount > count) {
            // 询问框
            layer.confirm(msg, {
                btn: ["确认"]
                // 按钮
            });
        } else {
            acupointLocationPediatricCount = acupointLocationPediatricCount + 1;
            var content;
            if (acupointLocationPediatricCount ==2 ) {
                content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6'><input type='text' "+validateAnswerText+" class='form-control' name='answer' placeholder=\"请输入答案......\"/></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2'><input type='text'  "+validateAnswerScoreLocationText+"class='form-control' name='answerScore' /></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"acupointLocationPediatricCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
            }else if(acupointLocationPediatricCount ==3){
                content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6'><input type='text' "+validateAnswerText+" class='form-control' name='answer' placeholder=\"请输入答案......\"/></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2'><input type='text' "+validateAnswerScoreLocationText+" class='form-control' name='answerScore' /></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"acupointLocationPediatricCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
            }
            $(divId).append(content);
        }
    }
    function  getTotalScoreAcupointLocationPediatric() {
        var location1ScorePediatric=$("#table-example").find("input[name='location1ScorePediatric']").val();
        var partScorePediatric=$("#table-example").find("input[name='partScorePediatric']").val();
        var partDetailScorePediatric=$("#table-example").find("input[name='partDetailScorePediatric']").val();
        var total=0.0;
        total = parseFloat(total) +parseFloat(location1ScorePediatric) + parseFloat(partScorePediatric) + parseFloat(partDetailScorePediatric);
        $("input[name='answerScore']").each(function(i){
            total=parseFloat($(this).val())+total;
        });
        return total;
    }
</script>
</html>
